<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                <form id="search-form" role="form" class="form-horizontal" autocomplete="off">
                    <input type="hidden" readonly id="productMember" name="productMember" class="form-control" value="${user.userRealname}">
                    <div class="form-group">
                        <label class="control-label col-sm-1">时间:</label>
                        <div class="col-sm-2">
                            <input type="text" id="inventoryDate" name="inventoryDate"   class="form-control">
                        </div>
                        <label class="control-label col-sm-1">渠道:</label>
                        <div class="col-sm-2">
                            <select id="inventoryChannelName" name="inventoryChannelName"  class="form-control">
                                <option value="">请选择</option>
                                <%for(var dict in channel){%>
                                <option value="${dict.channelName}">${dict.channelName}</option>
                                <%}%>
                            </select>
                        </div>
                        <label class="control-label col-sm-1">SKU:</label>
                        <div class="col-sm-2">
                            <input type="text" id="inventorySku" name="inventorySku" class="form-control">
                        </div>
                        <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-1">开始时间:</label>
                        <div class="col-sm-2">
                            <input type="text" id="inventoryBeginDate" name="inventoryBeginDate"   class="form-control">
                        </div>
                        <label class="control-label col-sm-1">结束时间:</label>
                        <div class="col-sm-2">
                            <input type="text" id="inventoryEndDate" name="inventoryEndDate"   class="form-control">
                        </div>
                        <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                    </div>
                </form>
            </div>
            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <a class="add-btn btn btn-sm btn-success"><i class="fa fa-plus" aria-hidden="true"></i> 测试</a>
                <button  class="export-btn layui-btn  layui-btn-sm" style="margin-left: -2px">
                    <i class="fa fa-download" aria-hidden="true"></i> 导出当前数据
                </button>
            </div>
            <!-- START 数据表格 -->
            <table id="relatedTable"
                   data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-side-pagination="server"
                   data-page-size="15"
                   data-url="/sea/finance/inventory/findByCnd.do"
                   class="table table-striped table-hover">
            </table>
            <!-- END 数据表格 -->

            <!-- END 右侧数据 -->
        </div>
    </div>
</div>

<!-- START 内容部分 -->
<div class="container" style="display: none;overflow-x: hidden;max-width: 600px" id="layer_window">
    <form class="form-horizontal" id="info-form" enctype="multipart/form-data" autocomplete="off" >
        <input type="text" id="testDate"  name="testDate"   class="form-control">
    </form>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="save-btn btn btn-primary">
                <i class="fa fa-save"></i> 保存
            </button>
        </div>
    </div>
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer,layui,upload'}){}%>
<script>
    laydate.render({
        elem: '#inventoryDate',
        type: 'month'
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#inventoryBeginDate',
        type: 'month'
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#inventoryEndDate',
        type: 'month'
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#testDate',
        type: 'month'
        ,trigger: 'click'
    });

    var $relatedTable = $('#relatedTable'),selections=[];
    $(function(){
        //指定允许上传的文件类型
        //START 表格配置
        $relatedTable.bootstrapTable({
            columns: [
                {
                    title: 'SKU',
                    field: 'inventorySku',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '渠道',
                    field: 'inventoryChannelName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '时间',
                    field: 'inventoryDate',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '期初数量',
                    field: 'inventoryBeginNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '调配数量',
                    field: 'inventoryChange',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '期初单价',
                    field: 'inventoryBeginPrice',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期初金额',
                    field: 'inventoryBeginMoney',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期初不含税单价',
                    field: 'inventoryBeginUnitPrice',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期初关税',
                    field: 'inventoryBeginCustomTax',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期初运费',
                    field: 'inventoryBeginCustomFreight',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '借方发生数量',
                    field: 'inventoryBorrowNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '入库单价',
                    field: 'inventoryBorrowPrice',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '不含税单价',
                    field: 'erpProduceUnitPrice',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '关税',
                    field: 'createCustomTax',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '运费',
                    field: 'createCustomFreight',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '借方发生金额',
                    field: 'inventoryBorrowMoney',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '贷方发生数量',
                    field: 'inventoryCreditNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '出库单价',
                    field: 'inventoryCreditPrice',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '贷方发生金额',
                    field: 'inventoryCreditMoney',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期末余额数量',
                    field: 'inventoryEndNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '结存单价',
                    field: 'inventoryEndPrice',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                } ,
                {
                    title: '期末余额金额',
                    field: 'inventoryEndMoney',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期末不含税单价',
                    field: 'inventoryEndUnitPrice',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期末关税',
                    field: 'inventoryEndCustomTax',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                },
                {
                    title: '期末运费',
                    field: 'inventoryEndCustomFreight',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r){
                        if(null == v){
                            return '';
                        }else {
                            return v.toFixed(2);
                        }
                    }
                }
            ],
            onLoadSuccess : function(){
                $('.edit-btn').on('click',function(){//新增
                    var id=$(this).attr('data-val');
                    layer.open({
                        title: false,
                        closeBtn: 0,
                        type: 2,
                        area: ['100%','100%'],
                        skin: 'layer-ext-espresso',
                        content: ['/sea/finance/rate/editPage.do?id='+id, 'yes']
                    });
                });

            }
        });
    });


    //提交表单
    $('.save-btn').on('click',function(){

        layer.confirm('确定要付款当前数据？', {
            btn: ['确定','取消'],title:'提示'
        }, function(){
            layer.closeAll();
            var index=layer.load();
            $.post('/sea/finance/inventory/test.do',{testDate:$("#testDate").val()},function(data){
                if( data.ok ){
                    $relatedTable.bootstrapTable('refresh');
                    layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']});
                    layer.close(index);
                }else{
                    layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                    layer.close(index);
                }
            });
        });
    });
    $('.search-btn').on('click',function(){
        $relatedTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/finance/inventory/findByCnd.do?'+$('#search-form').serialize() });
    });

    $('.add-btn').on('click',function(){

        layer.open({
            type:1,
            title:'确认日期',
            area:['600px','250px'],
            skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
            shadeClose:false,
            resize: false,
            scrollbar: false,
            maxmin: false,//出现最大化按钮
            content:$('#layer_window')
        })
    });

    $(".export-btn").click(function () {
        window.location.href='/sea/finance/inventory/export?'+$('#search-form').serialize();
    });
</script>
</body>
</html>
